const btn_post = document.querySelector('#login-post')
const btn = document.querySelector('#login')
const text = document.querySelector('#text')
const pwd = document.querySelector('#pwd')


btn.addEventListener('click',() => {
  fetch(`/api/login?username=${text.value}&password=${pwd.value}`).then(res => {
    res.json().then(res => {
      console.log(res)
    })
  })
})

btn_post.addEventListener('click',() => {
  fetch(`/api/loginpost`,{
    method:"POST",
    body:JSON.stringify({
      username: text.value,
      password: pwd.value
    }),
    headers: {
      "Content-Type":"application/json"
    }
  }).then(res => res.text()).then(res => {
      console.log(res)
  })
})